package com.zxy.ziems.server.file.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author chdzq
 * @create 2023/3/21
 */
public class DateUtil {
    public static Supplier<LocalDateTime> now = () -> {
        return LocalDateTime.now(ZoneId.of("+8"));
    };
    public static Supplier<Long> currentTime = () -> {
        return LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    };
    public static Function<LocalDateTime, Long> timestamp = (now) -> {
        return now.toInstant(ZoneOffset.of("+8")).toEpochMilli();
    };
    public static Function<String, String> todayStr = (format) -> {
        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(format);
        return LocalDate.now(ZoneId.of("+8")).format(fmt);
    };

    public DateUtil() {
    }
}

